﻿<Window x:Class="CloudClipboardSync.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:CloudClipboardSync="clr-namespace:CloudClipboardSync"
        xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit" Title="MainWindow" Height="350" Width="525"
        DataContext="{StaticResource programData}">
    <DockPanel>
        <StackPanel DockPanel.Dock="Top" VerticalAlignment="Top" HorizontalAlignment="Left">
            <Button Content="Refresh" Margin="10 10 10 0" Click="btnRefreshClick"/>
            <TextBlock x:Name="txtInfo" Margin="10 10 10 0" />
            <TextBlock Text="{Binding LastRefreshTime}" Margin="10 10 10 0" />
        </StackPanel>
        <!--<ListBox Margin="10" ItemsSource="{Binding ClipboardItems}"/>-->
        <ListBox ItemsSource="{Binding ClipboardHistory}" HorizontalContentAlignment="Stretch" SelectedItem="{Binding SelectedClipboard}">
            <ListBox.ItemTemplate>
                <DataTemplate DataType="CloudClipboardSync:ClipboardContent">
                    <Border BorderBrush="Silver" BorderThickness="0 0 0 1">
                        <DockPanel>
                            <TextBlock Text="{Binding Time}" DockPanel.Dock="Top" FontWeight="Bold" HorizontalAlignment="Center"/>                            
                    <Grid Margin="3">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="Auto" />
                        </Grid.ColumnDefinitions>
                        <Grid Grid.Column="0" MaxHeight="100">
                            <StackPanel Visibility="{Binding Rtf, Converter={StaticResource VisibleIfNotNull}}" MinWidth="200">
                                <TextBlock Text="Rtf" FontWeight="Bold" Margin="0 0 0 5"/>
                                <xctk:RichTextBox Text="{Binding Rtf, Mode=OneWay}" BorderThickness="0"
                                                  ScrollViewer.VerticalScrollBarVisibility="Auto" 
                                                  IsDocumentEnabled="false" IsReadOnly="true" Focusable="False" Background="Transparent"/>
                            </StackPanel>
                            <Grid Visibility="{Binding Rtf, Converter={StaticResource VisibleIfNull}}">
                                <StackPanel Visibility="{Binding Text, Converter={StaticResource VisibleIfNotNull}}" MinWidth="200">
                                    <TextBlock Text="Text" FontWeight="Bold" Margin="0 0 0 5"/>
                                    <TextBlock Text="{Binding Text, Mode=OneWay}"/>
                                </StackPanel>
                            </Grid>
                        </Grid>
                        <StackPanel Grid.Column="1" Visibility="{Binding Image, Converter={StaticResource VisibleIfNotNull}}"
                                    MaxHeight="100" HorizontalAlignment="Center">
                            <TextBlock Text="Image" FontWeight="Bold" Margin="0 0 0 5"/>
                            <Image Source="{Binding Image, Mode=OneWay}" />
                        </StackPanel>
                    </Grid>
                        </DockPanel>
                    </Border>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
    </DockPanel>
</Window>
